home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / emulator / patch-0.60 / patch-0.60.4-dpmi
Text File  |  1995-12-06  |  3KB  |  86 lines

  1. *** dpmi/dpmi.c.orig    Sat Nov  4 18:46:44 1995
  2. --- dpmi/dpmi.c    Wed Dec  6 11:33:33 1995
  3. ***************
  4. *** 190,195 ****
  5. --- 190,205 ----
  6.   #define vm86_regs sigcontext
  7.   #endif
  8.   unsigned long RealModeContext;
  9. + /*
  10. +  * With this stack nested PM programs like DJ200's make/compiler work fine
  11. +  * (maybe Borkland's protected mode make/compiler too).
  12. +  * For do_int31
  13. +  *     0x0300:    Simulate Real Mode Interrupt
  14. +  *     0x0301:    Call Real Mode Procedure With Far Return Frame
  15. +  *     0x0302:    Call Real Mode Procedure With Iret Frame
  16. +  */
  17. + unsigned long RealModeContext_Stack[DPMI_max_rec_rm_func];
  18. + unsigned long RealModeContext_Running = 0;
  19.   
  20.   static INTDESC Interrupt_Table[0x100];
  21.   static INTDESC Exception_Table[0x20];
  22. ***************
  23. *** 982,987 ****
  24. --- 992,1013 ----
  25.     /*2ch*/    *++lp = 0xffffffff;
  26.   }
  27.   
  28. + static inline void save_rm_context()
  29. + {
  30. +   if (RealModeContext_Running >= DPMI_max_rec_rm_func) {
  31. +     error("DPMI: RealModeContext_Running = 0x%4x\n",RealModeContext_Running++);
  32. +     return;
  33. +   }
  34. +   RealModeContext_Stack[RealModeContext_Running++] = RealModeContext;
  35. + }
  36. + static inline void restore_rm_context()
  37. + {
  38. +   if (RealModeContext_Running-- > DPMI_max_rec_rm_func)
  39. +     return;
  40. +   RealModeContext = RealModeContext_Stack[RealModeContext_Running];
  41. + }
  42.   static inline void save_rm_regs()
  43.   {
  44.     if (DPMI_rm_procedure_running >= DPMI_max_rec_rm_func) {
  45. ***************
  46. *** 1231,1236 ****
  47. --- 1257,1263 ----
  48.     case 0x0301:    /* Call Real Mode Procedure With Far Return Frame */
  49.     case 0x0302:    /* Call Real Mode Procedure With Iret Frame */
  50.       save_rm_regs();
  51. +     save_rm_context();
  52.       RealModeContext = GetSegmentBaseAddress(_es) + (DPMIclient_is_32 ? _edi : _LWORD(edi));
  53.       {
  54.         struct RealModeCallStructure *rmreg = (struct RealModeCallStructure *) RealModeContext;
  55. ***************
  56. *** 2088,2094 ****
  57.     my_sp = LWORD(esp);
  58.     NOCARRY;
  59.   
  60. !   save_rm_regs();
  61.   
  62.     REG(cs) = DPMI_SEG;
  63.     REG(eip) = DPMI_OFF + HLT_OFF(DPMI_return_from_dos);
  64. --- 2115,2123 ----
  65.     my_sp = LWORD(esp);
  66.     NOCARRY;
  67.   
  68. !   if(!in_dpmi) { /* Don't eat rm regs if already in dpmi */
  69. !     save_rm_regs();
  70. !   }
  71.   
  72.     REG(cs) = DPMI_SEG;
  73.     REG(eip) = DPMI_OFF + HLT_OFF(DPMI_return_from_dos);
  74. ***************
  75. *** 2944,2949 ****
  76. --- 2973,2979 ----
  77.   
  78.     } else if (lina == (unsigned char *) (DPMI_ADD + HLT_OFF(DPMI_return_from_realmode))) {
  79.       struct RealModeCallStructure *rmreg = (struct RealModeCallStructure *) RealModeContext;
  80. +     restore_rm_context();
  81.   
  82.       D_printf("DPMI: Return from Real Mode Procedure\n");
  83.   #ifdef SHOWREGS
  84.